package smetana.modules.ui.actions;

import com.google.inject.Inject;
import smetana.modules.ui.form.doc.DocEditPanel;
import smetana.modules.ui.form.doc.DocListPanel;
import smetana.modules.ui.form.window.WorkPanel;
import smetana.modules.ui.form.window.ToolbarPanel;

/**
 *
 * @author dmitry.mamonov
 */
public abstract class AbstractEditDocumentAction extends AbstractAction {
    @Inject
    ToolbarPanel toolbarPanel;

    @Inject
    WorkPanel workPanel;

    @Inject
    DocListPanel docListPanel;

    @Inject
    DocEditPanel docEditPanel;

    protected void handleLoadAndSwitch() {
        //edit panel
        docEditPanel.load();
        //work panel
        workPanel.switchToDocumentEdit();
    }

    protected void handleActionsAndToolbar() {
        //actions and toolbar
        this.actionDelete.setEnabled(false);
        this.actionCreate.setEnabled(false);
        toolbarPanel.getButtonEdit().setVisible(false);
        toolbarPanel.getButtonSave().setVisible(true);
    }
}
